Skip to content

Add JSONL output to theme dev - #8996

Open
isaacroldan wants to merge 5 commits into
codex/theme-dev-instancefrom
codex/theme-dev-json
Open

isaacroldan wants to merge 5 commits into
codex/theme-dev-instancefrom
codex/theme-dev-json

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Agents need structured live output from theme dev while the session runs.

WHAT is this pull request doing?

Add --json (-j) to stream the same JSONL bytes to stdout and the Dev Instance log. Reuse the shared log schema and writer; records contain timestamp and message, without type, stream, or source. Setup diagnostics use stderr, and fatal CLI errors use the standard JSON error envelope on stdout. Request and synchronization messages omit terminal timestamps and decoration; request paths remain complete. There is no final success result.

Disable terminal progress UI and hotkeys in JSON mode. Keep a named theme environment on the single-session path instead of collecting a finite batch result. Expose the record schema through --json-schema, update generated help/docs, and remove the app dev and theme dev lint exceptions now that both support typed JSON.

Stacked on #8976.

How to manually test your changes?

  1. Run pnpm shopify theme dev --path /path/to/theme --store your-store.myshopify.com --theme THEME_ID --json --no-input > /tmp/theme-dev.jsonl with existing authentication.
  2. Change an asset and open the local preview. Check the JSONL stream for synchronization and HTTP request messages.
  3. Press Ctrl+C once. Read the session's .shopify/dev/*.jsonl file and compare it with /tmp/theme-dev.jsonl; the bytes should match.
  4. Run pnpm shopify theme dev --json-schema to inspect the record and fatal-error schemas.

Validation

  • 515 focused tests pass across 34 files, covering theme sessions, shared output and Dev Instance behavior, app-dev compatibility, and the JSON lint rule. Type checking, changed-source lint, and the CLI build/bundle pass.
  • Eight subprocess cases cover text and JSON modes: SIGINT and SIGTERM after startup, SIGINT during crawler lookup, and SIGTERM during session initialization. They verify first-signal exit, ownership cleanup, and exact stdout/file equality in JSON mode. Running sessions retain all 1,000 queued messages plus shutdown output.
  • Output tests run real temporary-file synchronization and local HTTP requests. They check warning/error capture during Ink progress, full JSON request paths, optional durations, plain messages, and unchanged text formatting.
  • Command tests cover --json, -j, the environment variable, named/configured environments, --no-input, schemas, and fatal errors. The command tests leave the remembered theme store unchanged.
  • No live-store synchronization or manual Windows console test was performed.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact

@isaacroldan
isaacroldan requested review from a team as code owners October 23, 2026 10:15
@github-actions github-actions Bot added the Area: @shopify/theme @shopify/theme package issues label Oct 23, 2026
@isaacroldan
isaacroldan added this pull request to stack #8953 October 23, 2026 10:16
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm.

Built from 87bf45a8c7889f63dded3a8b0a0022ceb4458ee6. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261026102952

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@github-actions github-actions Bot added no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. and removed Area: @shopify/theme @shopify/theme package issues labels Oct 26, 2026
@isaacroldan
isaacroldan force-pushed the codex/theme-dev-json branch 2 times, most recently from eac3b4a to 36ee858 Compare October 26, 2026 13:01
@gonzaloriestra

Copy link
Copy Markdown
Contributor

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from 36ee858e20d082fc9d2474bc972cf644aec6793c. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261027112515

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Comment thread packages/theme/src/cli/services/dev/output.ts
@gonzaloriestra gonzaloriestra changed the title [Feature] Add JSONL output to theme dev Add JSONL output to theme dev Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/dev-instance-output.d.ts
@@ -2,18 +2,18 @@ import { zod } from '../../public/node/schema.js';
 import { Writable, type WritableOptions } from 'stream';
 export declare const devInstanceLogOutputSchema: import("../../public/node/json-output-schema.js").JsonOutputSchema<zod.ZodObject<{
     timestamp: zod.ZodString;
-    source: zod.ZodString;
+    source: zod.ZodOptional<zod.ZodString>;
     level: zod.ZodOptional<zod.ZodEnum<["debug", "info", "warning", "error"]>>;
     message: zod.ZodString;
 }, "strict", zod.ZodTypeAny, {
-    source: string;
     message: string;
     timestamp: string;
+    source?: string | undefined;
     level?: "info" | "error" | "debug" | "warning" | undefined;
 }, {
-    source: string;
     message: string;
     timestamp: string;
+    source?: string | undefined;
     level?: "info" | "error" | "debug" | "warning" | undefined;
 }>>;
 /** One line of a dev instance's JSON Lines log. */
@@ -30,7 +30,7 @@ export declare function createDevInstanceOutput({ logFile, logOutput, isActive,
         timestamp?: string;
     }) => Promise<void>;
     tee: (target: Writable, { source, stringWritesAreMessages }: {
-        source: string;
+        source?: string;
         stringWritesAreMessages?: boolean;
     }) => DevInstanceOutput;
     flush: () => Promise<PromiseSettledResult<void>[]>;
packages/cli-kit/dist/private/node/output-context.d.ts
@@ -2,6 +2,8 @@ export interface ConcurrentOutputContext {
     outputPrefix?: string;
     /** Controls ANSI stripping for terminal output. JSON diagnostics are always unstyled. */
     stripAnsi?: boolean;
+    /** Captures console messages before the terminal renderer handles them. */
+    consoleWarn?: (message: string) => void;
 }
 export declare function useConcurrentOutputContext<T>(context: ConcurrentOutputContext, callback: () => T): T;
 /** Returns the source and styling context for the current output write. */
packages/cli-kit/dist/public/node/dev-instance.d.ts
@@ -80,7 +80,8 @@ export interface DevInstance {
      * The returned stream forwards the original bytes to `target` unchanged.
      */
     tee: (target: Writable, options: {
-        source: string;
+        /** Omit the source field when the stream does not need to distinguish producers. */
+        source?: string;
         /** Treat each string write as a complete message. Byte writes remain buffered into lines. */
         stringWritesAreMessages?: boolean;
     }) => Writable;

@gonzaloriestra

Copy link
Copy Markdown
Contributor

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from 31116c688cd71ead1a43d02a2337a5e31fd275f3. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261027161634

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants